﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL.Entity;
namespace DAL.Persistencia
{
    public class ClassificacaoContabilDAL
    {

        private NewTierraEntities Con;

        public ClassificacaoContabilDAL()
        {

            Con = new NewTierraEntities();

        }



        public List<C_ClassificacaoContabil> ConsultarTodos()
        {

            try
            {
                return Con.C_ClassificacaoContabil.OrderBy(c => c.ClassificacaoContabil_nome).ToList();
            }
            catch 
            {
                throw;
            }
        }


        public C_ClassificacaoContabil ConsultarPorNome(string nome)
        {

            try
            {
                return Con.C_ClassificacaoContabil.Where(c => c.ClassificacaoContabil_nome.Equals(nome)).SingleOrDefault();
            }
            catch
            {
                throw;
            }
        }


        public C_ClassificacaoContabil ConsultarPorId(int id)
        {

            try
            {
                return Con.C_ClassificacaoContabil.Where(c => c.ClassificacaoContabil_id == id).SingleOrDefault();
            }
            catch
            {
                throw;
            }
        }

        public void incluir(C_ClassificacaoContabil c)
        {

            try
            {
                Con.AddToC_ClassificacaoContabil(c);
                Con.SaveChanges();
            }
            catch (Exception)
            {

                throw;
            }

        }


    }
}
